<?php
MYTCONN();
//==================== Procedures ============================
if (isset($_GET['ID'])) {
    $OB = $_GET['ID'];
} else {
    $OB = $_POST['ID'];
}
$Qr_rs = $GLOBALS['MYT']->db_array("SELECT
  				isr_ID,
				isr_Operacion,
				isr_User,
				isr_UserGroup,
				isr_Origen,
				isr_Client,
				stt_Word,
				isr_Status,
				isr_Time,
				ist_Name,
				ist_Name AS isr_Type,
				isr_Description,
				FraID, FraFechaIngreso, FraEnviado, CliNombre, BnfNombre
   FROM hd_isralert
   INNER JOIN facturas ON FraID = isr_Operacion
   INNER JOIN clientes ON clientes.CliNumero = Facturas.FraCliNumero
   INNER JOIN beneficiarios ON beneficiarios.BnfNumero = Facturas.FraBnfNumero
   INNER JOIN hd_sysstatus ON hd_sysstatus.sttFlag = isr_Status AND stt_Sistema = 14
   INNER JOIN hd_isrtypes ON ist_ID = isr_Type
					WHERE isr_ID = {$OB}");
for ($f = 1; $f <= $Qr_rs[0]; $f++) {
    //=====================Invoice Form=========================
    form_pr('Edit', '', $MODURL . 'pr_isr', 'post');
    mn_field('hidden', 'ED', 'ID', $OB, '', '', '', '');
    mn_field('hidden', 'ED', 'isr_Operacion', $Qr_rs[$f]['isr_Operacion'], '', '', '', '');
?>
    <table width="100%"  border="0" cellspacing="0" cellpadding="3">
        <tr bgcolor="#D1D2B5">
            <td width="45%">Informa&ccedil;&atilde;o do Alerta </td>
            <td><?php mn_field('button', 'ED', 'PR', 'Salvar', '', '', 'False', '" onclick="subform(\'Edit\',\'element\');'); ?></td>
        </tr>
        <tr>
            <td valign="top"><table width="100%" cellpadding="2" cellspacing="0">
                    <tr>
                        <td width="36%">ID Alerta: </td>
                        <td width="64%"><strong><?php echo $Qr_rs[$f]['isr_ID']; ?></strong></td>
                    </tr>
                    <tr>
                        <td colspan="2">Estado: <?php echo $Qr_rs[$f]['stt_Word']; ?></td>
                    </tr>
                    <tr>
                        <td>Operacion: </td>
                        <td><strong>
<?php echo $Qr_rs[$f]['isr_Operacion']; ?>
                        </strong></td>
                </tr>
                <tr>
                    <td>Opera&ccedil;&atilde;o</td>
                    <td><?php mn_field('checkbox', 'ED', 'ConfBlock', '', '', '', '', ''); ?>Liberar remessa </td>
                </tr>
                <tr>
                    <td>Fecha: </td>
                    <td><strong><?php echo $Qr_rs[$f]['isr_Time']; ?></strong></td>
                </tr>
                <tr>
                    <td>Status: </td>
                    <td><strong><?php
    $SearchStatus = "SELECT sttFlag AS ID, stt_Word AS NAME FROM hd_sysstatus WHERE stt_Sistema = 14";
    mn_field('select', 'ED', 'isr_Status', $Qr_rs[$f]['isr_Status'], $SearchStatus, '', 'False', 'inputbox');
?></strong></td>
                </tr>
            </table></td>
        <td><table width="100%" cellpadding="2" cellspacing="1">
                <tr>
                    <td colspan="3" valign="top">Anexos <?php mn_field('button', 'ED', 'Enviar ficheiros', 'Anexar ficheiro', '', '', '', 'inputbox"
onClick="newwindow(\'_response/call.php?get=Compliance/amh_docadd&ID=' . $Qr_rs[$f]['isr_ID'] . '\',\'Uploader\');'); ?></td>
                </tr>
                <?php
                $Docs = $GLOBALS['MYT']->db_array("SELECT * FROM hd_docdocumentos
	  		INNER JOIN hd_doctipos ON dnc_ID = dnl_TipoDoc
	   WHERE dnl_AML = 0
	   AND dnl_CL = {$Qr_rs[$f]['isr_Client']}");
                for ($d = 1; $d <= $Docs[0]; $d++) {
                    if ($d == 1) {
                ?>
                        <tr bgcolor="#E9D9A0">
                            <td valign="top">Tipo</td>
                            <td valign="top">Ficheiro</td>
                            <td valign="top">Data</td>
                        </tr>
<?php } ?>
                    <tr bgcolor="#E7EBE0">
                        <td valign="top"><?php echo $Docs[$d]['dnc_Doc']; ?></td>
                    <td valign="top"><a href="_response/bin.php?img=<?php
                        $DCEXT = strlen($Docs[$d]['dnl_FILE']);
                        $DCEXT = substr($Docs[$d]['dnl_FILE'], $DCEXT - 3, 3);
                        echo md5($Docs[$d]['dnl_ID']) . '.' . $DCEXT;
?>"><?php echo $Docs[$d]['dnl_FILE']; ?></a></td>
                    <td valign="top"><?php echo $Docs[$d]['dnl_FechaEntrega']; ?></td>
                        </tr>
<?php } ?>
                    <tr>
                        <td colspan="3" valign="top"><p>Motivo <b><?php echo $Qr_rs[$f]['ist_Name']; ?></b>
                            <br>Observa&ccedil;&otilde;es<br>
<?php mn_field('textarea', 'ED', 'isr_Description', $Qr_rs[$f]['isr_Description'], '60', '4', '', ''); ?></td>
                </tr>
            </table></td>
    </tr>
</table>
</form>
<table width="100%" cellpadding="2" cellspacing="0">
    <tr>
        <td colspan="5">Ordem Relacionada</td>
    </tr>
    <tr bgcolor="#CCCCCC">
        <td>Operacion</td>
        <td>Fecha</td>
        <td>Remitente </td>
        <td>Destinatario </td>
        <td>Montante</td>
    </tr>
    <tr>
        <td><?php echo $Qr_rs[$f]['FraID']; ?></td>
        <td><?php echo $Qr_rs[$f]['FraFechaIngreso']; ?></td>
        <td><?php echo $Qr_rs[$f]['BnfNombre']; ?></td>
        <td><?php echo $Qr_rs[$f]['CliNombre']; ?></td>
        <td><?php echo $Qr_rs[$f]['FraEnviado']; ?></td>
    </tr>
</table>
<?php } ?>